package org.example.mybatis.extend.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import lombok.*;

import java.io.Serializable;

@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@TableName(value = "ANIMAL")
public class Animal {
    @TableId(value = "ID", type = IdType.AUTO)
    private Integer id;
    @TableField(value = "NAME", exist = true)
    private String name;
    //    @TableField(value = "TYPE", exist = true)
//    private AnimalType type;
//    @TableField(value = "SEX", exist = true)
//    private AnimalSex sex;
    @TableField(value = "MASTER", exist = true)
    private String master;


    public static enum AnimalType implements IEnum {
        CAT("1", "猫"), DOG("2", "狗"), TIGER("3", "虎"), MOUSE("4", "鼠"), MONKEY("5", "猴"), LOAN("6", "狮"), OTHER("7", "其他");
        private final String value;
        private final String desc;

        AnimalType(final String value, final String desc) {
            this.value = value;
            this.desc = desc;
        }

        @Override
        public Serializable getValue() {
            return value;
        }

        public String getDesc() {
            return desc;
        }
    }

    public static enum AnimalSex implements IEnum {
        MALE("1", "公"), FEMALE("2", "母");
        private final String value;
        private final String desc;

        AnimalSex(final String value, final String desc) {
            this.value = value;
            this.desc = desc;
        }

        @Override
        public Serializable getValue() {
            return value;
        }

        public String getDesc() {
            return desc;
        }
    }
}
